Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow configuration of a pre-execution hook for arbitrary conditions #56

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

d10r
Copy link

@d10r d10r commented Jun 6, 2017

On my notebook, I wanted automatic updates to be done only when connected to Ethernet and AC Power.
Since I didn't find a way to do this with unattended-upgrades as is, I added a config option which allows to make execution dependent on arbitrary conditions by executing a given script and checking its return value.

Usage described in README.md

As an example, that's the script I'm using it with (tailored to my system):

#!/bin/bash

set -e
set -u

ETH_CONNECTED=false
AC_CONNECTED=false

# check Ethernet connected
if [[ `cat /sys/class/net/eth0/operstate` == "up" ]]; then
  ETH_CONNECTED=true
fi

# check AC connected
if [[ `cat /sys/devices/platform/smapi/ac_connected` == 1 ]]; then
  AC_CONNECTED=true
fi

if $ETH_CONNECTED && $AC_CONNECTED; then
  exit 0
fi

exit 1

@rbalint
Copy link
Collaborator

rbalint commented Jul 12, 2017

In typical configurations the processes calling unattended-upgrade implement that thus I think there would be little value in adding the feature to u-u, too.
https://anonscm.debian.org/git/apt/apt.git/commit/?id=51d659e7d8cdce59f910eceeee68e2c2afdb70d4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants